<%--
    Document   : listtime
    Created on : Nov 24, 2011, 10:47:13 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.ThamSoHT,Models.ThamSoHT_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'timename', 'timelist', 'time', 'status', 'rightmsg', 'order', 'notice', 'enable', 'disable', 'all' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();            
            String disable = mdsts[1].getTenTS();
            String enable = mdsts[2].getTenTS();
            String notice = mdsts[3].getTenTS();
            String order = mdsts[4].getTenTS();
            String rightmsg = mdsts[5].getTenTS();
            String status = mdsts[6].getTenTS();
            String time = mdsts[7].getTenTS();
            String timelist = mdsts[8].getTenTS();
            String timename = mdsts[9].getTenTS();

            String msgright = notice + "/" + rightmsg;            

            Vector vDSTD = (Vector) request.getAttribute("DSTD");
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vDSTD.size();
            if (vsize % 4 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 4;
            } else {
                numpage = vsize / 4 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String sapxep = (String) request.getAttribute("order");
            String test = (String) request.getAttribute("test");
            String sort = (String) request.getAttribute("sort");
            String sortkv = (String) request.getAttribute("sortkv");
            String sx1 = "";
            String sx2 = "";
            String ud1 = "";
            String ud2 = "";
            if(sapxep.equals("desc") ){
                   sx1 = "down";
                   sx2 = "down";
                   ud1 = "down1";
                   ud2 = "down1";
            }            
            else if(sapxep.equals("asc") && test.equals("1")){
                    sx1 = "up";
                    sx2 = "down";
                    ud1 = "up1";
                    ud2 = "down1";
            }
            else{
                    sx1 = "down";
                    sx2 = "up";
                    ud1 = "down1";
                    ud2 = "up1";
            }
%>
<div class="title">
        <%=timelist%>
        
    </div>
    <div class="content">
        <form name="dsthoidiem" action="">
            <table class="mytable" border="0" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th style="width: 10%;  "><%=order%></th>
                        <th style="width: 30%; ">
                            <a href="#" id="titledskv1" style="margin-top: 5px;" class="<%=sx1%>" name="1" lang="<%=msgright%>" onclick="SortTenTD(this.className, this.name, this.lang)">
                                <div style="float:left"><%=timename%></div>
                                <div id="sortkv1" style=" margin-right: 30px;" class="<%=ud1%>"></div>
                            </a>
                        </th>
                        <th style="width: 31%; ">
                            <a href="#" id="titledskv2" style="margin-top: 5px;" >
                                <%=time%>
                            </a>
                        </th>
                        <th>
                            <a href="#" id="titledskv3" style="margin-top: 5px;" class="<%=sx2%>" name="1" lang="<%=msgright%>" onclick="SortTTTD(this.className, this.name, this.lang)">
                                <div style="float:left"><%=status%></div>
                                <div id="sortkv3" style=" margin-right: 20px;" class="<%=ud2%>"></div>
                            </a>
                        </th>
                    </tr>
                    <tr id="searchTD">
                        <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" alt="1" src="../images/search1.png" lang="<%=msgright%>" onclick="SearchTime(this.alt, this.lang)"></th>
                        <th><input type="textbox" style=" width: 120px;" class="tentd text" ></th>
                        <th></th>
                        <th>
                            <select class="tinhtrang" id="1"  lang="<%=msgright%>" onchange="SearchTime( this.id, this.lang)">
                                <option value="all"><%= all%></option>
                                <option value="1"><%=enable%></option>
                                <option value="0"><%=disable%></option>
                            </select>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <%
                        for (int i = (item - 1) * 4; i < (item - 1) * 4 + 4 && i < vsize; i++) {
                            Beans.ThoiDiem td = (Beans.ThoiDiem) vDSTD.elementAt(i);
                    %>
                    <tr>
                        <td class="STT"><%= i + 1%></td>
                        <td><a href="#" name="<%=td.getMaTD() %>" lang="<%=msgright%>" onclick="ShowLangTime(this.name, this.lang)"><%=td.getTenTD() %></a></td>
                        <td><div style=" width: 40px; float: left;"><%=td.getTuGio() %> : <%=td.getTuPhut()%></div><div style="float: left">-</div><div style=" width: 40px; float: left; margin-left: 15px;"><%=td.getDenGio() %> : <%=td.getDenPhut() %></div></td>
                        <td>
                            <select  class="<%= td.getMaTD()%>" lang="<%=msgright%>" onchange="UpdateStatusTime(this.value,  this.className, this.lang)">
                                <%
                                    if (td.getTinhTrang() == 1) {%>
                                        <option value="1"><%= enable%></option>
                                        <option value="0"><%= disable%></option>
                                <%  } else {%>
                                        <option value="0"><%= disable%></option>
                                        <option value="1"><%= enable%></option>
                                <%  }
                                %>
                            </select>
                        </td>

                    </tr>
                    <%  }
                    %>
                </tbody>
            </table>
            <div class="pagination">
                <%
                            int trang = 1;
                            if (item > 1) {
                                trang = item - 1;
                            }
                %>
                <%
                                if (vsize > 4) {%>
                <%
                    if(sortkv.equals("tentd")){%>
                        <a href="#" id="<%=sort %>" class="prev"  title="<%= trang%>" lang="<%=msgright%>" onclick="SortTenTD( this.id, this.title, this.lang)">«</a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort %>" class="prev"  title="<%= trang%>" lang="<%=msgright%>" onclick="SortTTTD( this.id, this.title, this.lang)">«</a>
                <%  }
                %>
                
                <%
                                                    for (int c = 1; c <= numpage; c++) {

                                                        if (c != item) {
                %>
                <%
                    if(sortkv.equals("tentd")){%>
                        <a href="#" id="<%=sort %>" name="<%= c%>" lang="<%=msgright%>" onclick="SortTenTD( this.id, this.name, this.lang)" ><%= c%></a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort %>" name="<%= c%>" lang="<%=msgright%>" onclick="SortTTTD( this.id, this.name, this.lang)" ><%= c%></a>
                <%  }
                %>
                <% } else {%><a class="current"> <%= c%></a> <% }

                                                    }
                %>
                <%
                                                    if (item + 1 <= numpage) {
                                                        trang = item + 1;
                                                    } else {
                                                        trang = item;
                                                    }
                %>
                <%
                    if(sortkv.equals("tentd")){%>
                    <a href="#" id="<%=sort %>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortTenTD( this.id, this.name, this.lang)">»</a>
                <%  }
                    else{%>
                    <a href="#" id="<%=sort %>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortTTTD( this.id, this.name, this.lang)">»</a>
                <%  }
                %>
                <%  }
                %>
            </div>
        </form>
    </div>
